package com.egao.orderB.controller;

import com.egao.common.core.annotation.ApiPageParam;
import com.egao.common.core.annotation.OperLog;
import com.egao.common.core.damon.results.PageResult2;
import com.egao.common.core.web.BaseController;
import com.egao.common.core.web.JsonResult;
import com.egao.orderB.entity.TableColumnUser;
import com.egao.orderB.service.TableColumnUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 *
 * 用户表格显示列配置
 * @author : Doman
 * @date : 2021-09-01 15:20:33
 * @version ：1.0
 */

@Api(tags = "用户表格显示列配置")
@RestController
@RequestMapping("/api/orderB/tableColumnUser")
public class TableColumnUserController extends BaseController {

	@Autowired
	private TableColumnUserService tableColumnUserService;

	/**
	 * 分页查询列表
	 */
	//@PreAuthorize("hasAuthority('orderB:tableColumnUser:list')")
    //@OperLog(value = "用户表格显示列配置", desc = "分页查询")
    @ApiOperation(value ="分页查询用户表格显示列配置",notes = "" +
        "limit:每页显示几行 必填\n" +
        "page:第几页 必填\n" +
        " \n\n\n" +
        "返回的结果:\n" +
        "id:id\n" +
        "userId:用户id\n" +
        "columnId:客户id\n" +
        "orderNum:序号\n" +
        "showIs: 是否显示列 1显示  0隐藏  只是保存的时候用\n" +
        "show: 是否显示列 true  false  真正返回的\n" +
        "remark:备注\n" +
        "createTime:创建时间\n" +
        "createUser:创建人\n" +
        "updateTime:更新时间\n" +
        "updateUser:更新人\n" +
        "",httpMethod = "POST")
    @ApiPageParam
    @PostMapping("/page")
    public JsonResult page(PageResult2<T> page, TableColumnUser tableColumnUser) throws Exception{
        return tableColumnUserService.list(page, tableColumnUser, getLoginUser());
    }

    /**
     * 查询全部用户表格显示列配置
     */
    //@PreAuthorize("hasAuthority('orderB:tableColumnUser:list')")
    //@OperLog(value = "用户表格显示列配置", desc = "查询全部")
    @ApiOperation(value ="查询全部用户表格显示列配置",notes = "" +
            "userId:用户id\n" +
            " \n\n\n" +
            "返回的结果:\n" +
            "id:id\n" +
            "userId:用户id\n" +
            "columnId:客户id\n" +
            "orderNum:序号\n" +
            "showIs: 是否显示列 1显示  0隐藏  只是保存的时候用\n" +
            "show: 是否显示列 true  false  真正返回的\n" +
            "remark:备注\n" +
            "createTime:创建时间\n" +
            "createUser:创建人\n" +
            "updateTime:更新时间\n" +
            "updateUser:更新人\n" +
            "",httpMethod = "POST")
    @PostMapping("/list")
    public JsonResult list(TableColumnUser tableColumnUser){
        return tableColumnUserService.list(tableColumnUser, getLoginUser());
    }

    /**
     * 根据id查询用户表格显示列配置
     */
    //@PreAuthorize("hasAuthority('orderB:tableColumnUser:list')")
    //@OperLog(value = "用户表格显示列配置", desc = "根据id查询")
    @ApiOperation("根据id查询用户表格显示列配置")
    @PostMapping("/get")
    public JsonResult get(TableColumnUser tableColumnUser) {
        return tableColumnUserService.getById(tableColumnUser);
		// 使用关联查询
        //PageParam<tableColumnUser> pageParam = new PageParam<>();
		//pageParam.put("id", id);
        //List<tableColumnUser> records = tableColumnUserService.listAll(pageParam.getNoPageParam());
        //return JsonResult.ok().setData(pageParam.getOne(records));
    }


    /**
     * 添加用户表格显示列配置
     */
    //@PreAuthorize("hasAuthority('orderB:tableColumnUser:save')")
    @OperLog(value = "用户表格显示列配置", desc = "添加", param = false, result = true)
    @ApiOperation(value ="添加用户表格显示列配置",notes = "" +
            "userId:用户id\n" +
            "columnId:客户id\n" +
            "showIs: 是否显示列\n" +
        "",httpMethod = "POST")
    @PostMapping("/save")
    public JsonResult save(Model model, TableColumnUser tableColumnUser) {
        return tableColumnUserService.save(tableColumnUser, getLoginUser());
    }

    /**
     * 修改用户表格显示列配置
     */
    //@PreAuthorize("hasAuthority('orderB:tableColumnUser:update')")
    @OperLog(value = "用户表格显示列配置", desc = "修改", param = false, result = true)
    @ApiOperation(value ="修改用户表格显示列配置",notes = "" +
            "id:id\n" +
            "showIs: 是否显示列 1显示  0隐藏\n" +
        "",httpMethod = "POST")
    @PostMapping("/update")
    public JsonResult update(Model model, TableColumnUser tableColumnUser) {
        return tableColumnUserService.update(tableColumnUser, getLoginUser());
    }

    /**
     * 删除用户表格显示列配置
     */
    //@PreAuthorize("hasAuthority('orderB:tableColumnUser:remove')")
    @OperLog(value = "用户表格显示列配置", desc = "删除", result = true)
    @ApiOperation("删除用户表格显示列配置")
    @PostMapping("/remove")
    public JsonResult remove(TableColumnUser tableColumnUser ) {
        return tableColumnUserService.remove(tableColumnUser, getLoginUser());
    }

    /**
     * 批量添加用户表格显示列配置
     */
    /**@RequiresPermissions("orderB:tableColumnUser:save")
    @OperLog(value = "用户表格显示列配置", desc = "批量添加", param = false, result = true)
    @ResponseBody
    @PostMapping("/saveBatch")
    public JsonResult saveBatch(@RequestBody List<TableColumnUser> list) {
        if (tableColumnUserService.saveBatch(list)) {
            return JsonResult.ok("添加成功");
        }
        return JsonResult.error("添加失败");
    }*/

    /**
     * 批量修改用户表格显示列配置
     */
    /**@RequiresPermissions("orderB:tableColumnUser:update")
    @OperLog(value = "用户表格显示列配置", desc = "批量修改", result = true)
    @ResponseBody
    @PostMapping("/updateBatch")
    public JsonResult updateBatch(@RequestBody BatchParam<TableColumnUser> batchParam) {
        if (batchParam.update(tableColumnUserService, "")) {
            return JsonResult.ok("修改成功");
        }
        return JsonResult.error("修改失败");
    }*/

    /**
     * 批量删除用户表格显示列配置
     */
    /**@RequiresPermissions("orderB:tableColumnUser:remove")
    @OperLog(value = "用户表格显示列配置", desc = "批量删除", result = true)
    @ResponseBody
    @PostMapping("/removeBatch")
    public JsonResult removeBatch(@RequestBody List<Integer> ids) {
        if (tableColumnUserService.removeByIds(ids)) {
            return JsonResult.ok("删除成功");
        }
        return JsonResult.error("删除失败");
    }*/

}
